package com.qf.strategy.receivemsg;

import com.qf.strategy.service.DataFilterManager;
import com.qianfeng.smsplatform.common.constants.RabbitMqConsants;
import com.qianfeng.smsplatform.common.model.Standard_Submit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.zip.DataFormatException;

/**
 * @author 徐老板
 * @date 2020/2/27   14:58
 */
@Component
public class ReceiveMsg {
    private static final Logger LOGGER = LoggerFactory.getLogger(ReceiveMsg.class);
    @Resource
    DataFilterManager dataFilterManager;


//这里获取bean的方式只需要把名字写过来就可以了 这个之前不知道
    //傻逼了 这里其实需要的是一个常量 所以你注入半天一直报错
//    @RabbitListener(queues = RabbitMqConsants.TOPIC_PRE_SEND,containerFactory ="taskContainerFactory")
    @RabbitListener(queues = RabbitMqConsants.TOPIC_PRE_SEND,containerFactory ="taskContainerFactory")
    public void receiveMsg(Standard_Submit submit){
        LOGGER.error("收到的内容是{}",submit);
        try {
            dataFilterManager.dealSms(submit);
        } catch (DataFormatException e) {
            e.printStackTrace();
            LOGGER.error("接收信息这里出现了错误:{}",e.getMessage());
        }
    }
}
